package com.bright.cwduijie;

import com.bright.cwduijie.common.util.StringUtil;
import com.bright.cwduijie.duijie.constant.SystemConstants;
import com.bright.cwduijie.duijie.util.EntityManagerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
//@EnableCaching
@EnableScheduling
@EnableTransactionManagement
public class CwDuijieShengApplication extends SpringBootServletInitializer implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(CwDuijieShengApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(CwDuijieShengApplication.class);
    }

    /**
     * 获取当前连接数据库的类型 默认是SQLServer
     */
    @Value("${database.type:sqlserver}")
    public String dataBaseType;

    @Override
    public void run(String... args) throws Exception {
        // 初始化参数赋值
//        System.out.println("初始加载时使用dataBaseType" + dataBaseType);

        if (StringUtil.equalsIgnoreCase(dataBaseType, "dm")) {
            EntityManagerUtil.IS_DM = true;
        }
    }
}
